package com.gxa.autoparts.portal.service.impl;

import com.gxa.autoparts.core.pojo.Coupon;
import com.gxa.autoparts.portal.mapper.CheckMyCouponMapper;
import com.gxa.autoparts.portal.service.CheckMyCouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("checkMyCouponService")
public class CheckMyCouponServiceImpl implements CheckMyCouponService {
    @Autowired
    CheckMyCouponMapper checkMyCouponMapper;
    @Override
    public List<Coupon> unusedCouponList(Long id) {
        return checkMyCouponMapper.unusedCouponList(id);
    }

    @Override
    public List<Coupon> usedCouponList(Long id) {
        return checkMyCouponMapper.usedCouponList(id);
    }

    @Override
    public List<Coupon> expiredCouponList(Long id) {
        return checkMyCouponMapper.expiredCouponList(id);
    }

    @Override
    public Coupon getById(Long id) {
        Coupon coupon = checkMyCouponMapper.selectByPrimaryKey(id);
        return coupon;
    }

    @Override
    public Map<String, Object> getCouponInfoByUserId(Long userId) {
        HashMap<String, Object> map = new HashMap<>(16);
        List<Coupon> notGetCoupon = checkMyCouponMapper.getNotGetCoupon(userId);
        List<Coupon> coupons = checkMyCouponMapper.getedCoupon(userId);
        map.put("notGetCoupon",notGetCoupon);
        map.put("coupons",coupons);
        return map;
    }

}
